package pcjavanet.mobilesell.service;

import java.util.List;

import pcjavanet.mobilesell.model.Department; 
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.DepartmentExample;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.model.QryTerm;
import pcjavanet.mobilesell.persistence.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class DepartmentService {


  @Autowired
  private  DepartmentMapper departmentMapper;


  public int  insert( Department department ) throws Exception{
	return departmentMapper.insert (department);
  }


  public Department  selectByPrimaryKey( Department  bean ) {
 	int dbid = bean.getDbid();
	Department department = departmentMapper.selectByPrimaryKey( dbid );
	return department ;
  }


  public int  updateByPrimaryKeySelective( Department department ) throws Exception{
	return departmentMapper.updateByPrimaryKeySelective( department );
  }


  public int  deleteByPrimaryKey( Department  bean ) throws Exception{
 	int dbid = bean.getDbid();
	return departmentMapper.deleteByPrimaryKey( dbid );
  }


  public List<Department>  selectByExample( Department department ) throws Exception{
    DepartmentExample example = new DepartmentExample();
	return departmentMapper.selectByExample( example );
  }

  public List<Department>  getOnePageBeans( QryCondition condition , PageBean pageBean ) throws Exception{
    DepartmentExample example = new DepartmentExample();
    ServiceUtil.dealCriteria( condition,  example.createCriteria() );
	List<Department> ls=departmentMapper.getOnePageBeans( example , pageBean );
//begin
	if ( ls.size() > 0 ) {
	}
//end
	return ls;
  }

  public int getTotalRecords( QryCondition condition , PageBean pageBean ) throws Exception{
    DepartmentExample example = new DepartmentExample();
    ServiceUtil.dealCriteria( condition,  example.createCriteria() );
	return departmentMapper.getTotalRecords( example , pageBean );
  }

  public int countByExample( Department department , PageBean pageBean ){
    DepartmentExample example = new DepartmentExample();
	return departmentMapper.countByExample( example );
  }
  public List<Department> selectByExamplePage( Department department , PageBean pageBean ){
  DepartmentExample example = new DepartmentExample();
	return departmentMapper.selectByExamplePage( example , pageBean );
  }

}
